import { Module } from 'vuex'
import request from '@/utils/request'
type RelationInfoState = {
	/* 联系人名称 */
	ContactName : string,
	/* 联系人电话 */
	ContactTelephone : string,
	/* 联系人手机 */
	ContactMobilePhone : string,
	/* 联系人邮箱 */
	ContactMail : string,
	/* vip */
	vip:'vip1'|'vip2'|'vip3'|''
}
const relationInfo : Module<RelationInfoState, never> = {
	state: {
		ContactMail: '',
		ContactMobilePhone: '',
		ContactName: '',
		ContactTelephone: '',
		vip:''
	},
	mutations: {
		editRelationInfo(state, option : RelationInfoState) {
			state.ContactName = option.ContactName || ''
			state.ContactTelephone = option.ContactTelephone || ''
			state.ContactMobilePhone = option.ContactMobilePhone || ''
			state.ContactMail = option.ContactMail || ''
		},
	},
	actions: {
		getRelationInfo(context) {
			/* 获取联系人信息信息 */
			request.get('/api/Company/GetCompanyInfo?companyId=1').then(res => {

				context.commit('editRelationInfo',
					{
						ContactName: res.Data.ContactName,
						ContactTelephone: res.Data.ContactTelephone,
						ContactMobilePhone: res.Data.ContactMobilePhone,
						ContactMail: res.Data.ContactMail
					}
				)
			})
		}
	},
	namespaced: true
}
export default relationInfo